home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / sgverinf / ENUMFILE.VBS < prev    next >
Encoding:
Text File  |  1998-08-17  |  4.6 KB  |  130 lines

  1. '--------------------------------------------------------------------------
  2. ' EnumFiles.vbs - Enumerates files from the system directory and prints
  3. '                 version information for files that have it.
  4. '
  5. ' This file is part of the sgVersionInfo.
  6. ' Copyright (C) 1998 Stinga
  7. ' All rights reserved.
  8. '
  9. ' This source code demonstrates usage of the sgVersionInfo component
  10. ' and it's string properties.
  11. '--------------------------------------------------------------------------
  12.  
  13. ' sgFileFlag constants
  14. const sgVS_FF_DEBUG           = &H00000001
  15. const sgVS_FF_PRERELEASE      = &H00000002
  16. const sgVS_FF_PATCHED         = &H00000004
  17. const sgVS_FF_PRIVATEBUILD    = &H00000008
  18. const sgVS_FF_INFOINFERRED    = &H00000010
  19. const sgVS_FF_SPECIALBUILD    = &H00000020
  20.  
  21. ' sgFileOS constants
  22. const sgVOS_UNKNOWN           = &H00000000
  23. const sgVOS_DOS               = &H00010000
  24. const sgVOS_OS216             = &H00020000
  25. const sgVOS_OS232             = &H00030000
  26. const sgVOS_NT                = &H00040000
  27. const sgVOS__BASE             = &H00000000
  28. const sgVOS__WINDOWS16        = &H00000001
  29. const sgVOS__PM16             = &H00000002
  30. const sgVOS__PM32             = &H00000003
  31. const sgVOS__WINDOWS32        = &H00000004
  32. const sgVOS_DOS_WINDOWS16     = &H00010001
  33. const sgVOS_DOS_WINDOWS32     = &H00010004
  34. const sgVOS_OS216_PM16        = &H00020002
  35. const sgVOS_OS232_PM32        = &H00030003
  36. const sgVOS_NT_WINDOWS32      = &H00040004
  37.  
  38. ' sgFileType constants
  39. const sgVFT_UNKNOWN           = &H00000000
  40. const sgVFT_APP               = &H00000001
  41. const sgVFT_DLL               = &H00000002
  42. const sgVFT_DRV               = &H00000003
  43. const sgVFT_FONT              = &H00000004
  44. const sgVFT_VXD               = &H00000005
  45. const sgVFT_STATIC_LIB        = &H00000007
  46.  
  47. ' sgFileSubtype constants
  48. const sgVFT2_UNKNOWN          = &H00000000
  49. const sgVFT2_DRV_PRINTER      = &H00000001
  50. const sgVFT2_DRV_KEYBOARD     = &H00000002
  51. const sgVFT2_DRV_LANGUAGE     = &H00000003
  52. const sgVFT2_DRV_DISPLAY      = &H00000004
  53. const sgVFT2_DRV_MOUSE        = &H00000005
  54. const sgVFT2_DRV_NETWORK      = &H00000006
  55. const sgVFT2_DRV_SYSTEM       = &H00000007
  56. const sgVFT2_DRV_INSTALLABLE  = &H00000008
  57. const sgVFT2_DRV_SOUND        = &H00000009
  58. const sgVFT2_DRV_COMM         = &H0000000A
  59. const sgVFT2_DRV_INPUTMETHOD  = &H0000000B
  60. const sgVFT2_FONT_RASTER      = &H00000001
  61. const sgVFT2_FONT_VECTOR      = &H00000002
  62. const sgVFT2_FONT_TRUETYPE    = &H00000003
  63.  
  64. ' Create some objects
  65. set VerInfo = WScript.CreateObject("sgVersionInfo.VersionInfo")
  66. Set fs      = WScript.CreateObject("Scripting.FileSystemObject")
  67. Set foldr   = fs.GetFolder(WScript.Path)
  68.  
  69. On Error Resume Next
  70. Dim sMsg
  71. Dim vbCrLf
  72. vbCrLf = Chr(13) + Chr(10)
  73.  
  74. ' Are we running from command line
  75. Dim bFromCmdLine
  76. bFromCmdLine = false
  77. if InStrRev(UCase(WScript.FullName), "CSCRIPT") then bFromCmdLine = true
  78.  
  79. ' Scan all files in the folder
  80. For Each File In foldr.Files
  81.  
  82.     Err.Number = 0
  83.     sMsg = ""
  84.     
  85.     ' Try to get version info for current file
  86.     VerInfo.Path = File.Path
  87.     if Err.Number = 0 then
  88.         ' No error. Display version info if file contains any
  89.         if VerInfo.InfoExist then
  90.             sMsg = UCase(file.Name) + " - " + VerInfo.FileDescription + vbCrLf
  91.             sMsg = sMsg + "Product Name: "      + VerInfo.ProductName + vbCrLf
  92.             sMsg = sMsg + "File Version: "      + VerInfo.FileVersion + vbCrLf
  93.             sMsg = sMsg + "Product Version: "   + VerInfo.ProductVersion + vbCrLf
  94.             sMsg = sMsg + "Company Name: "      + VerInfo.CompanyName + vbCrLf
  95.             sMsg = sMsg + "Internal Name: "     + VerInfo.InternalName + vbCrLf
  96.             sMsg = sMsg + "Original Filename: " + VerInfo.OriginalFilename + vbCrLf
  97.             sMsg = sMsg + "Private Build: "     + VerInfo.PrivateBuild + vbCrLf
  98.             sMsg = sMsg + "Special Build: "     + VerInfo.SpecialBuild + vbCrLf
  99.             sMsg = sMsg + "Legal Copyright: "   + VerInfo.LegalCopyright + vbCrLf
  100.             sMsg = sMsg + "Legal Trademarks: "  + VerInfo.GetValue("StringFileInfo", "LegalTrademarks") + vbCrLf
  101.             sMsg = sMsg + "Language: "          + VerInfo.LanguageName + vbCrLf
  102.             sMsg = sMsg + "Comments: "          + VerInfo.Comments + vbCrLf
  103.             sMsg = sMsg + "OS: "                + VerInfo.FileOSString + vbCrLf
  104.  
  105.             if bFromCmdLine then
  106.                 WScript.Echo sMsg
  107.             else
  108.                 rc = MsgBox(sMsg, 1)
  109.                 if rc = 2 then WScript.Quit(0)
  110.             end if
  111.         end if
  112.     else
  113.         ' An error occured or file does not have version info
  114.         sMsg = File.Path & ": " & vbCrLF & _
  115.                Err.Description & vbCrLf & _
  116.                "Error #:" & CStr(Err.Number)
  117.         if bFromCmdLine then
  118.             WScript.Echo sMsg
  119.         else
  120.             MsgBox sMsg
  121.         end if
  122.     end if
  123. next
  124.  
  125. MsgBox "Finished"
  126.  
  127. set VerInfo = nothing
  128. Set fs      = nothing
  129. Set foldr   = nothing
  130.